<?php

class usermgr_model extends Hardy_mysql_handler
{
	function __construct()
	{
		parent::__construct('localhost', 'root', 'qzmphardy', 'test');
	}
	function __destruct()
	{
		parent::__destruct();
	}
	
	public function match($user, $password)
	{
		mysql_escape_string($user);
		mysql_escape_string($password);
		$userID = $this->query("SELECT time FROM users WHERE username='$user' AND password='$password'");
		if(count($userID)) return true; else return false;
	}
	public function find($user)
	{
		mysql_escape_string($user);
		$userID = $this->query("SELECT time FROM users WHERE username='$user'");
		if(count($userID)) return true; else return false;
	}
	public function find_all()
	{
		return $this->query("SELECT username FROM users");
	}
	public function add($user, $password)
	{
		mysql_escape_string($user);
		mysql_escape_string($password);
		mysql_query("INSERT INTO users (username, password, time) VALUES('$user', '$password', '".date("Y-m-d H:i:s")."')");
	}
	public function delete($user)
	{
		mysql_escape_string($user);
		mysql_query("DELETE FROM users WHERE username='$user'");
	}
}

?>